﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability.App.Apilication.Common.Slaughter;
using Traceability.Domain;
using Traceability.ErrorCode;

namespace Traceability.App.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SlaughterController : ControllerBase
    {
        private readonly IMediator mediator;

        public SlaughterController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 屠宰信息添加
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> CreateSlaughterHandle(CreateSlaughterCommon request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 根据批次显示屠宰信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiPaimg<SlaughterModel>> GetSlaughterHandle([FromQuery]GetSlaughterCommon request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 添加屠宰企业信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> CreateSlaughterEnterHandle(CreateSlaughterEnterComon request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 根据批次查询屠宰企业
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<SlaughteringEnterprises>>> GetSlaughterEnterHandle([FromQuery]GetSlaughterEnterComon request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 修改屠宰信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<ApiResult<int>> UpdateSlaughterHandle(UpdateSlaughterCommon request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 修改屠宰企业信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<ApiResult<int>> UpdateSlaughterEnterHandle(UpdateSlaughterEnterComon request)
        {
            return mediator.Send(request);
        }


        }
}
